import {Injectable} from "@angular/core";
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/catch';
import {Observable} from "rxjs/Observable";
import {Http} from "@angular/http";
import {UrlData} from "../../common/urldata";
import {ExceptionHandler} from "../../common/exception.handler";

@Injectable()
export class MessageService {

  constructor(private http: Http, private urlData: UrlData, private exceptionHandler: ExceptionHandler) {
  }

  findByToken(param: { token: string; size: number; page: number }): Observable<any> {
    return this.http
      .get(this.urlData.baseUrl + `v1/message/personal` + param.token, {params: param})
      .timeout(5000)
      .map(res => res.json())
      .catch(err => this.exceptionHandler.handleError(err));

  }
}
